#pragma once

#include <opencv2\opencv.hpp>
#include <fstream>

#include "MLAlgo.h"
#include "MLEvaluation.h"
#include "KeySort.h"

using namespace cv;
using namespace std;

class SupervisedLearning
{
private:
	Mat data;
	Mat labels;
	MLEvaluation eval;

	void readData (string fdata);
	void readLabels (string flabels);

public:
	SupervisedLearning ();
	SupervisedLearning (int numRows, int numCols);
	void read(string fdata, string flabels);
	void read(string fdata, string flabels, Mat v);
	int countNumberOfAttributes(Mat d);
	virtual void train() = 0;
	virtual void train_auto() = 0;
	virtual float predict(Mat& sample) = 0;
	virtual void constructConfusionMatrix() = 0;
	void evaluate();
	Mat getData();
	Mat getLabels();
	Mat confusion;
	int k;

	void printEvaluation();

	int numberOfElements;
	int numberOfAttributes;
	float percentOfLeaders;
	float percentOfMutants;
	int numberOfIterations;

	vector<KeySort> initializeVector(int n, int numOfAtt); 

	void initializeGeneticAlgorithm(const int numberOfElements,
								const int numberOfAttributes,
								const int numberOfIterations,
								const float percentOfLeaders,
								const float percentOfMutants);
	vector<KeySort> initializeElements();
	Mat createDataMat(vector<KeySort> d, int n);
	Mat createLabelsMat(vector<KeySort> data, int n);
	vector<KeySort> crossOverAll(vector<KeySort>& elems);
	void SupervisedLearning::crossOver(Mat& parent1, Mat& parent2, Mat& child1, Mat& child2);
	void plot (Mat dat);

};